<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : menu.xsl
    Created on : Utorok, 2010, apríl 20, 12:23
    Author     : Football-Statistics Team
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" media-type="html/text"/>
    <xsl:param name="loc_results"/>
    <xsl:param name="loc_standings"/>
    <xsl:param name="loc_statistics"/>
    <xsl:param name="context"/>
    <xsl:param name="lid"/>
    <xsl:param name="section"/>
    <xsl:template match="/leagues">
        <ul class="sf-menu sf-navbar">
        <xsl:for-each select="league">
            <xsl:choose>
                <xsl:when test="$lid=season/@id">
                    <xsl:call-template name="league_current"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="league"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        </ul>
    </xsl:template>
    
    <xsl:template name="league_current">
        <li class="current">
        <a href="#"><xsl:value-of select="name"/></a>
        <ul>
        <xsl:for-each select="season">
            <xsl:choose>
                <xsl:when test="$lid=@id">
                    <xsl:call-template name="season_current"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="season"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        </ul>
        </li>    
    </xsl:template>
    
    <xsl:template name="league">
        <li>
        <a href="#"><xsl:value-of select="name"/></a>
        <ul>
        <xsl:for-each select="season">
            <xsl:choose>
                <xsl:when test="$lid=@id">
                    <xsl:call-template name="season_current"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="season"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        </ul>
        </li>        
    </xsl:template>
    
    <xsl:template name="season_current">
        <li class="current">
        <a href="#"><xsl:value-of select="."/></a>
        <ul>
            <xsl:choose>
                <xsl:when test="$section='results'">
                    <xsl:call-template name="section_results"/>
                </xsl:when>
                <xsl:when test="$section='standings'">
                    <xsl:call-template name="section_standings"/>
                </xsl:when>
                <xsl:when test="$section='statistics'">
                    <xsl:call-template name="section_statistics"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="section"/>
                </xsl:otherwise>
            </xsl:choose>
        </ul>
        </li>
    </xsl:template>

    <xsl:template name="season">
        <li>
        <a href="#"><xsl:value-of select="."/></a>
        <ul>
            <xsl:choose>
                <xsl:when test="$section='results' and $lid=@id">
                    <xsl:call-template name="section_results"/>
                </xsl:when>
                <xsl:when test="$section='standings' and $lid=@id">
                    <xsl:call-template name="section_standings"/>
                </xsl:when>
                <xsl:when test="$section='statistics' and $lid=@id">
                    <xsl:call-template name="section_statistics"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="section"/>
                </xsl:otherwise>
            </xsl:choose>
        </ul>
        </li>
    </xsl:template>
    
    <xsl:template name="section">
            <li><a href="{$context}/matches?lid={@id}" target="_self"><xsl:value-of select="$loc_results"/></a></li>
            <li><a href="{$context}/standings?lid={@id}&amp;hg=both&amp;fh=full"><xsl:value-of select="$loc_standings"/></a></li>
            <li><a href="{$context}/statistics?lid={@id}"><xsl:value-of select="$loc_statistics"/></a></li>
    </xsl:template>
    
    <xsl:template name="section_results">
            <li class="current"><a href="{$context}/matches?lid={@id}" target="_self"><xsl:value-of select="$loc_results"/></a></li>
            <li><a href="{$context}/standings?lid={@id}&amp;hg=both&amp;fh=full"><xsl:value-of select="$loc_standings"/></a></li>
            <li><a href="{$context}/statistics?lid={@id}"><xsl:value-of select="$loc_statistics"/></a></li>
    </xsl:template>
    
    <xsl:template name="section_standings">
            <li><a href="{$context}/matches?lid={@id}" target="_self"><xsl:value-of select="$loc_results"/></a></li>
            <li class="current"><a href="{$context}/standings?lid={@id}&amp;hg=both&amp;fh=full"><xsl:value-of select="$loc_standings"/></a></li>
            <li><a href="{$context}/statistics?lid={@id}"><xsl:value-of select="$loc_statistics"/></a></li>
    </xsl:template>
    
    <xsl:template name="section_statistics">
            <li><a href="{$context}/matches?lid={@id}" target="_self"><xsl:value-of select="$loc_results"/></a></li>
            <li><a href="{$context}/standings?lid={@id}&amp;hg=both&amp;fh=full"><xsl:value-of select="$loc_standings"/></a></li>
            <li class="current"><a href="{$context}/statistics?lid={@id}"><xsl:value-of select="$loc_statistics"/></a></li>
    </xsl:template>
</xsl:stylesheet>
